@inject('storeService', 'App\App\Services\StorageService')
@inject('VoteCandidate', 'App\Models\VoteCandidate\VoteCandidate')
@php
if(empty($activity->rule)){
$basic="{}";
$specs="[]";
$specs_isopen = 0;
}else{
$rule = json_decode($activity->rule,true);
if (empty($rule['basic'])){
$basic="{}";
}else{
$basic = json_encode($rule['basic']);
}
if (empty($rule['spec'])){
$specs="[]";
$specs_isopen = 0;
}else{
$specs =$rule['spec']['isopen']==1? (isset($rule['spec']['list'])?$rule['spec']['list']:[]):[];
$specs_isopen = $rule['spec']['isopen'];
foreach ($specs as $key=> &$item){
$item['id'] = $key;
}
unset($item);
$specs = json_encode($specs);
}

}
if (!empty($activity->shares)){
$share = $activity->shares;
$shareArray = json_decode($share,true);
$shareArray['isopen'] = isset($shareArray['isopen'])?$shareArray['isopen']:0;
$shareArray['thumb'] = isset($shareArray['thumb'])?$shareArray['thumb']:'';
$shareArray['qrcode'] = isset($shareArray['qrcode'])?$shareArray['qrcode']:'';
}else{
$shareArray = ['landindPage'=>0,'isopen'=>0,'thumb'=>'','qrcode'=>''];
$shareArray['icon'] = isset($shareArray['icon'])?$shareArray['icon']:'';
$share = json_encode($shareArray);
}
@endphp
<div class="text-left">
    <ul class="nav nav-icons" role="tablist">
        <li class="active">
            <a href="#activity_tab_0" role="tab" data-toggle="tab" aria-expanded="true">
                内容设置
            </a>
        </li>
        <li>
            <a href="#activity_tab_1" role="tab" data-toggle="tab" aria-expanded="true">
                规则设置
            </a>
        </li>
        <li>
            <a href="#activity_tab_2" role="tab" data-toggle="tab" aria-expanded="true">
                自定义设置
            </a>
        </li>
        <li>
            <a href="#activity_tab_3" role="tab" data-toggle="tab" aria-expanded="true">
                竞猜设置
            </a>
        </li>
    </ul>
</div>
<div class="tab-content">
    <div class="tab-pane active" id="activity_tab_0">
        <div class="card">
            <div class="content">
                <div class="form-group">
                    <label class="col-md-2 control-label">活动名称</label>
                    <div class="col-md-7">
                        <input class="form-control" type="text" ng-model="activity.name" name="name" data-msg="请输入活动名称"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">活动时间</label>
                    <div class="col-md-7">
                        <div class="row service-charges">
                            <div class="col-md-5 service-charges-name service-charges-name-0" style="padding-left: 15px;">
                                <input type="text" placeholder="开始时间"  name="startTime" data-msg="请输入开始时间" value="{{$activity->startTime}}" class="form-control datetimepicker">
                            </div>
                            <div class="col-md-5 service-charges-remark service-charges-remark-0">
                                <input type="text" placeholder="结束时间"   data-msg="请输入结束时间" name="endTime" value="{{$activity->endTime}}" class="form-control datetimepicker">
                            </div>

                        </div>
                    </div>
                </div>
                @php
                if(!empty($activity->limit)){
                $limit = json_decode($activity->limit,true);
                }else{
                $limit = [
                'num'=>1,
                'type'=>\App\Models\Activity\Activity::ACTIVITY_LIMIT_DAY_TYPE
                ];
                }
                @endphp
                <div class="form-group">
                    <label class="col-md-2 control-label">活动次数</label>
                    <div class="col-md-7">
                        <div class="row service-charges">
                            <label class="control-label pull-left" style="padding-left: 15px;">每人可抽奖</label>
                            <div class="col-md-9 input-group">
                                <input type="number" placeholder="参与次数"  value="{{$limit['num']}}"  name="limit[num]" min="1" data-msg="请输入参与次数" class="form-control">
                                <div class="input-group-addon">
                                    <select name="limit[type]" id="" class="">
                                        <option value="{{\App\Models\Activity\Activity::ACTIVITY_LIMIT_DAY_TYPE}}" @if($limit['type'] == \App\Models\Activity\Activity::ACTIVITY_LIMIT_DAY_TYPE) selected @endif >次/每日</option>
                                        <option value="{{\App\Models\Activity\Activity::ACTIVITY_LIMIT_ALL_TYPE}}" @if($limit['type'] == \App\Models\Activity\Activity::ACTIVITY_LIMIT_ALL_TYPE) selected @endif>次/活动全程</option>
                                    </select>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>

                <div class="form-group backgroundImg-container" style="display: none;">
                    <label class="col-md-2 control-label">更换背景</label>
                    <div class="col-md-7">
                        <input type="file" name="upfile" accept="image/gif,image/jpeg,image/png" data-target="uploadImageFile" data-for="backgroundImg" data-preview-file-type="text" class="form-control" value="" title="">
                        <input type="hidden" ng-model="activity.previewData.background" name="backgroundImg"  data-preview="{{$storeService->tomedia($activity->backgroundImg)}}" value="{{$activity->backgroundImg}}">
                        <span class="help-block">640*1200像素，支持PNG、JPG格式，小于100KB</span>
                    </div>
                </div>
                <div class="form-group backgroundColor-container" style="display: none;">
                    <label class="col-md-2 control-label">背景颜色</label>
                    <div class="col-md-7 input-group colorPicker colorpicker-component" data-format="alias">

                        <input type="text" value="{{$activity->backgroundColor}}" name="backgroundColor" class="form-control" />
                        <span class="input-group-addon"><i></i></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">活动介绍</label>
                    <div class="col-md-7">
                        <textarea class="form-control tinymceEditor" name="description">
                            {{$activity->description}}
                        </textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="tab-pane" id="activity_tab_1" ng-app="myapp" ng-init="myval=123" ng-controller="myctrl">
        <div class="card">
            <div class="content" style="padding:10px 30px;">
                <div class="form-group">
                    <label class="control-label" style="text-align:left;text-indent:7px;">口令类型:</label>
                    <label class="checkbox-inline" ng-show="false">
                        <input type="radio" value="1" :checked="codeType"  name="codetype"> 固定口令
                    </label>
                    <label class="checkbox-inline">
                        <input type="radio" value="2" :checked="!codeType"  name="codetype"> 定时口令
                    </label>
                </div>
                <div class="form-group">
                    <label class="col-md-12 control-label" style="text-align:left;">中奖规则:</label>
                    <div class="col-md-12">
                        <table class="table" style="border:1px solid #eeeeee;">
                            <thead style="background: rgb(241, 241, 241);text-align:center;">
                                <tr>
                                    <td style="width:40%">类型</td>
                                    <td style="width:19%">口令</td>
                                    <td style="width:25%">中奖奖品</td>
                                    <td style="width:11%">库存</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="width:40%">
                                        <label class="checkbox-inline">
                                            <input type="radio" value="1" name="codetype1"> 唯一口令
                                        </label>
                                        <label class="checkbox-inline">
                                            <input type="radio" value="2" name="codetype1"> 随机口令
                                        </label>
                                    </td>
                                    <td style="width:19%"><input class="form-control" style="text-align:center;background:#f4f8fb" type="text" placeholder="填写口令"></td>
                                    <td style="width:25%"><input class="form-control" type="text" style="text-align:center;background:#f4f8fb"></td>
                                    <td style="width:11%"><input class="form-control" type="text" style="text-align:center;background:#f4f8fb"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="col-md-12">
                        <table class="table" style="border:1px solid #eeeeee;">
                            <thead style="background: rgb(241, 241, 241);text-align:center;">
                                <tr>
                                    <td style="width:40%">开启时间</td>
                                    <td style="width:19%">口令</td>
                                    <td style="width:25%">中奖奖品</td>
                                    <td style="width:11%">库存</td>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="width:40%">
                                        <div class="input-group command-rule">
                                            <input type="text" class="form-control date-input border-right-none ng-pristine ng-untouched ng-isolate-scope ng-invalid ng-invalid-required" required=""> 
                                            <span class="input-group-addon border-right-none">至</span> 
                                            <input type="text" class="form-control date-input ng-pristine ng-untouched ng-isolate-scope ng-invalid ng-invalid-required" required="">
                                        </div>
                                    </td>
                                    <td style="width:19%"><input class="form-control" style="text-align:center;background:#f4f8fb" type="text" placeholder="填写口令"></td>
                                    <td style="width:25%"><input class="form-control" type="text" style="text-align:center;background:#f4f8fb"></td>
                                    <td style="width:11%"><input class="form-control" type="text" style="text-align:center;background:#f4f8fb"></td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-12" style="line-height: 38px;">本模板添加奖品数量1 ～ 50个。<button style="background: rgb(251, 64, 75);color:#ffffff;" class="btn btn-danger pull-right">添加奖品</button></div>
                </div>
                <div class="form-group">
                    <div class="col-md-12" style="line-height: 38px;">提示：口令文件需要CSV格式,每次最多导入10000条记录。</div>
                </div>
                <div class="form-group">
                    <div class="col-md-12" style="line-height: 38px;"><button style="background: rgb(251, 64, 75);color:#ffffff;" class="btn btn-danger"  ng-click="test($event)">保 存</button></div>
                </div>
            </div>
        </div>
    </div>
    <div class="tab-pane " id="activity_tab_2">
        <div class="card">
            <div class="content">
                <div class="form-group" ng-show="activity.category == 1">
                    <label class="col-md-2 control-label">开启分享</label>
                    <div class="col-md-7" >
                        <div class="switch" data-on-label="是" data-off-label="否" data-on-color="success">
                            <input type="checkbox" name="share[isopen]" value="1" @if($shareArray['isopen'] == 1) checked @endif>
                        </div>
                    </div>
                </div>
                <div class="form-group" ng-if="activity.category == 2">
                    <div class="col-md-7 col-md-offset-2" >
                        <label class="checkbox-inline">
                            <input type="checkbox" ng-checked="activity.share.landindPage == 1" ng-click="selectLandindPage(1)" name="share[landindPage]" value="1"> 活动落地页
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" ng-checked="activity.share.landindPage == 2" ng-click="selectLandindPage(2)" name="share[landindPage]" value="2"> 自定义落地页
                        </label>
                    </div>
                </div>
                <div class="form-group" ng-if="activity.category == 2" ng-show="activity.share.landindPage == 2">
                    <label class="col-md-2 control-label">落地页面</label>
                    <div class="col-md-7">
                        <input class="form-control" type="text" ng-value="activity.share.share_url"
                               name="share[share_url]" placeholder="示例：http://www.baidu.com"
                        />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">app下载链接</label>
                    <div class="col-md-7">
                        <input class="form-control input-enroll-self-appurl" type="text" name="app_url" value="{{$activity->app_url}}"  placeholder="配置app下载链接"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">分享图标</label>
                    <div class="col-md-7">
                        <input type="file" name="upfile" accept="image/gif,image/jpeg,image/png" data-for="share[icon]" file-upload data-preview-file-type="text" class="form-control" value="" title="">
                        <input type="hidden" name="share[icon]" data-preview="{{$storeService->tomedia($shareArray['icon'])}}" value="{{$shareArray['icon']}}">
                        <span class="help-block">200 * 200像素，支持PNG、JPG格式，小于20KB</span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">分享标题</label>
                    <div class="col-md-7">
                        <input class="form-control" type="text" ng-value="activity.share.title"
                               name="share[title]"
                        />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">分享文案</label>
                    <div class="col-md-7">
                        <textarea class="form-control" rows="3" name="share[description]">@{{activity.share.description}}</textarea>
                    </div>
                </div>
                <div class="form-group" ng-if="activity.category == 1">
                    <label class="col-md-2 control-label">上传二维码</label>
                    <div class="col-md-7">
                        <input type="file" name="upfile" accept="image/gif,image/jpeg,image/png" data-for="share[qrcode]" file-upload data-preview-file-type="text" class="form-control" value="" title="">
                        <input type="hidden" name="share[qrcode]" data-preview="{{$storeService->tomedia($shareArray['qrcode'])}}" value="{{$shareArray['qrcode']}}">
                        <span class="help-block">200 * 200像素，支持PNG、JPG格式，小于20KB</span>
                    </div>
                </div>
                <div class="form-group" ng-if="activity.category == 2" ng-show="activity.share.landindPage == 1">
                    <label class="col-md-2 control-label">底部图片</label>
                    <div class="col-md-7">
                        <input type="file" name="upfile" accept="image/gif,image/jpeg,image/png" data-for="share[qrcode]" file-upload data-preview-file-type="text" class="form-control" value="" title="">
                        {{--                        <input type="hidden" name="share[qrcode]" data-preview="{{$storeService->tomedia($shareArray['qrcode'])}}" value="{{$shareArray['qrcode']}}">--}}
                        <span class="help-block">640 * 98像素，支持PNG、JPG格式，小于50KB</span>
                    </div>
                </div>
                <div class="form-group" ng-if="activity.category == 2" ng-show="activity.share.landindPage == 1">
                    <label class="col-md-2 control-label">iOS下载地址</label>
                    <div class="col-md-7">
                        <input class="form-control" type="text" ng-value="activity.share.download.ios"
                               name="share[download][ios]"
                        />
                    </div>
                </div>
                <div class="form-group" ng-if="activity.category == 2" ng-show="activity.share.landindPage == 1">
                    <label class="col-md-2 control-label">安卓下载地址</label>
                    <div class="col-md-7">
                        <input class="form-control" type="text" ng-value="activity.share.download.android"
                               name="share[download][android]"
                        />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="tab-pane" id="activity_tab_3">
        <div class="card">
            <div class="content">
                <div class="form-group">
                    <label class="col-md-2 control-label">竞猜选项</label>
                    <div class="col-md-10" >
                        <div class="competition-card">
                            <div class="card competition-form" data-index=0>
                                <div class="content">
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <img src="/images/admin/delet_red.png"
                                                 class="competition_card_delet pull-right mgb10 mgr30">
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-2 control-label">竞猜标题</label>
                                            <div class="col-md-7">
                                                <input class="form-control" type="text"  placeholder="请输入竞猜标题"
                                                       name="competition-title" data-msg="请输入竞猜标题"
                                                />
                                            </div>
                                        </div>
                                        <div class="competition-option-card col-sm-10 col-md-offset-1">
                                            <div class="card competition-option-form" id="0_option_container_0" data-index=0>
                                                <div class="content">
                                                    <div class="row">
                                                        <div class="col-sm-12">
                                                            <img src="/images/admin/delet_red.png"
                                                                 class="competition_option_card_delet pull-right mgb10 mgr30">
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-md-2 control-label">选项标题</label>
                                                            <div class="col-md-7">
                                                                <input class="form-control" type="text"  placeholder="请输入选项标题"
                                                                       name="competition-option-title" data-msg="请输入选项标题"
                                                                />
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <div class="col-md-7 col-md-offset-2">
                                                                <label class="checkbox-inline">
                                                                    <input type="checkbox" name="answer"> 正确答案
                                                                </label>
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-md-2 control-label">选择图像</label>
                                                            <div class="col-md-7">
                                                                <input type="file" name="upfile" accept="image/gif,image/jpeg,image/png" data-target="uploadImageFile" data-for="backgroundImg" data-preview-file-type="text" class="form-control" value="" title="">
                                                                <input type="hidden"  name="backgroundImg" value="">
                                                            </div>
                                                        </div>
                                                        <div class="form-group">
                                                            <label class="col-md-2 control-label">选项详情</label>
                                                            <div class="col-md-7">
                                                                <textarea class="form-control" rows="3" name="share[description]"></textarea>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="pull-center mgud add-competition-option">
                                                <button type="button"
                                                        class="btn btn-info btn-wd btn-finish add-competition-option-butten">
                                                    +添加选项
                                                </button>
                                            </div>
                                        </div>

                                    </div>
                                </div>
                            </div>
                            <div class="pull-right add-competition">
                                <button type="button"
                                        class="btn btn-info btn-wd btn-fill btn-finish add-competition-butten">
                                    +添加竞猜
                                </button>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    /*初始化竞猜中的方法*/
    //initialCompetitionOpt();
    // new Vue({
    //     el: '#activity_tab_1',
    //     data: {
    //         codeType: true
    //     }
    // })
        // console.log(angular);
        var app = angular.module('myapp', []);

        app.controller('myCtrl', function($scope) {
            $scope.firstName = "John";
            $scope.lastName = "Doe";
        });


</script>

